import Vue from 'vue';
import VueRouter from 'vue-router'
import Layout from '../views/Layout/index.vue'
import Home from '../views/Home/index'
import Ranking from '../views/Ranking/index'
import HotSinger from '../views/HotSinger/index'
import Play from '../views/Play/index'
import Search from '../views/Search/index'

import NotFound from '../views/404/404.vue'
import Singer from '../views/Singer/index'
import Album from '../views/Album/index'
import MusicList from '../views/MusicList/index'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/layout'
    // 页面刚加载就跳转
  },
  {
    path: '/layout',
    // 主页
    component: Layout,
    redirect: '/layout/home',
    // 进入layout页面立即跳转到/home页面
    children: [{
      path: 'home',
      // 主页
      name: 'home',
      meta: { keepAlive: true },
      component: Home
    }, {
      path: 'ranking',
      // 排行榜页面
      name: 'ranking',
      meta: { keepAlive: true },
      component: Ranking
    }, {
      path: 'hotSinger',
      // 热门歌手页面
      name: 'hotSinger',
      meta: { keepAlive: true },
      component: HotSinger
    }, {
      path: "play",
      // 播放音乐页面
      name: 'play',
      meta: { keepAlive: false },
      component: Play
    }, {
      path: 'search',
      // 搜索页
      name: 'search',
      meta: { keepAlive: false },
      component: Search
    }, {
      path: 'singer',
      // 歌手页面
      name: 'singer',
      meta: { keepAlive: false },
      component: Singer
    }, {
      path: 'album',
      name: 'album',
      meta: { keepAlive: false },
      component: Album
    }, {
      path: 'musicList',
      name: 'musicList',
      meta: { keepAlive: false },
      component: MusicList
    }]
  },
  {
    path: '*',
    component: NotFound
  }
]

const router = new VueRouter({ routes: routes })
export default router